#include <bits/stdc++.h>
#define int long long
using namespace std;
// char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
// #define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
    while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
    return x*f;
}
const int N=1e6+5,mod=998244353;
#define pow Pow
int pow(int x,int base){
    int ans=1;
    while(base){
        if(base&1) ans=ans*x%mod;
        x=x*x%mod;
        base>>=1;
    }
    return ans;
}
int inv(int x){
    return pow(x,mod-2);
}
int n,m,jc[N*2],a[N],ans,f[N];
int C(int n,int m){
    if(n<0||m<0||m<n) return 0;
    return jc[m]*inv(jc[m-n])%mod*inv(jc[n])%mod;
}
int c(int n,int m){
    return C(n,n+m-1);
}
signed main(){
    freopen("count.in","r",stdin);
    freopen("count.out","w",stdout);
    n=read(),m=read();
    jc[0]=1;
    for(int i=1;i<=n+m;i++) jc[i]=jc[i-1]*i%mod;
    a[0]=1;
    for(int i=1;i<=n;i++) a[i]=read()+1;
    for(int i=1;i<=n;i++){
        for(int j=a[i-1];j<a[i];j++) ans=(ans+c(n-i,m-j+1))%mod;
        if(a[i]<a[i-1]){
            ans--;
            break;
        }
    }
    cout<<ans;
    return 0;
}